#pragma once
#include "DBall.h"
#include "../DWorld.h"
#include "../DVector3.h"
#include "DJointGroup.h"

namespace Skill
{
	namespace Ode
	{
		namespace Joints
		{		
			void DBall::CollectManagedMemory()
			{
				_Anchor1 = nullptr;
				_Anchor2 = nullptr;
				DJoint::CollectManagedMemory();
			}
			DBall::DBall(DWorld^ world , DJointGroup^ group)
				:DJoint(world,group)
			{
				dWorldID w = world? world->_This : NULL;
				dJointGroupID g = group? group->_This : NULL;
				_SetPointer(dJointCreateBall(w,g),true);
			}

			DVector3^ DBall::Anchor1::get()
			{
				if(!_Anchor1)
					_Anchor1 = gcnew DVector3();
				dJointGetBallAnchor(_This,_Anchor1->_This);
				return _Anchor1;
			}
			void DBall::Anchor1::set(DVector3^ value)
			{
				dJointSetBallAnchor(_This,value->_This[0],value->_This[1],value->_This[2]);
			}
			DVector3^ DBall::Anchor2::get()
			{
				if(!_Anchor2)
					_Anchor2 = gcnew DVector3();
				dJointGetBallAnchor2(_This,_Anchor2->_This);
				return _Anchor2;
			}
			void DBall::Anchor2::set(DVector3^ value)
			{
				dJointSetBallAnchor2(_This,value->_This[0],value->_This[1],value->_This[2]);
			}


			
			void DBall::SetParam(DJointParameters parameter, dReal value)
			{
				dJointSetBallParam(_This,(int)parameter, value);
			}
			dReal DBall::GetParam(DJointParameters parameter)
			{
				return dJointGetBallParam(_This,(int)parameter);
			}
		}
	}
}